<?php

/**
 * Deomstrates 'Factory' pattern
 * Specific ResponseData types are generated here at runtime as shown below
 * @author Sukhbir Singh Grewal
 *
 */
class ResponseFactory
{
	public static function Create($data, $response_type = 'json')
	{
		if(empty($response_type) || empty($data))
			throw new ExceptionHandler('Missing arguments for response factory');
		//for this example we assume acceptable response types are JSON, AMF, XML etc. which we just denote below for sake of not writing decode methods for each type
		$response_type = 'json';

		switch($response_type)
		{
			case 'json':
				return new JSONResponse($data);				
			//similarly can handle other types below
			/*case 'amf':
				break;
			case 'xml':
				break;*/
			default:
				throw new ExceptionHandler('Unknown response type received');
		}
	}
}